package com.yanghui.lingyue.utils.operationUtils

object OperationCodeUtils {

    fun getCodeFromCommand(command: String): Int {
        val instructionList = command.split(" ")
        return when (instructionList[0]) {
            "Like" -> 0
            "Get" -> when (instructionList[1]) {
                "-Like" -> 10
                else -> -1
            }
            "DriftBottle" -> when (instructionList[1]) {
                "-Get" -> when (instructionList[2]) {
                    "-Local" -> 20
                    "-Global" -> 21
                    else -> -1
                }
                "-Add" -> when (instructionList[2]) {
                    "-Local" -> 22
                    "-Global" -> 23
                    else -> -1
                }
                "-Like" -> 24
                else -> -1
            }
            "Balance" -> 30
            "ArknightRand" -> 40
            "Satellite" -> 50
            "MoePic" -> 60
            "RandSeed" -> 70
            "AIReply" -> 80
            "Motto" -> 90
            "LinePic" -> 100
            "Bread" -> when (instructionList[1]) {
                "-Buy" -> 110
                "-Rob" -> 111
                "-Check" -> 112
                else -> -1
            }
            else -> -1
        }
    }

    fun getCommandFromCode(code: Int): String {
        return when (code) {
            0 -> "Like"
            10 -> "Get -Like"
            20 -> "DriftBottle -Get -Local"
            21 -> "DriftBottle -Get -Global"
            22 -> "DriftBottle -Add -Local"
            23 -> "DriftBottle -Add -Global"
            24 -> "DriftBottle -Like"
            30 -> "Balance"
            40 -> "ArknightRand"
            50 -> "Satellite"
            60 -> "MoePic"
            70 -> "RandSeed"
            80 -> "AIReply"
            90 -> "Motto"
            100 -> "LinePic"
            else -> ""
        }
    }
}